{extend name="public/base"}
{block name="main"}
<div class="container" id="main">
    <div class="text-right">
        <button class="btn btn-info"><a href="{:url('category/create')}">添加分类</a> </button>
    </div>
    <table class="table">
        <caption>文章分类列表</caption>
        <thead>
        <tr>
            <th>分类名称</th>
            <th>是否显示</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        {volist name="list" id="vo"}
            <tr>
                <td>{if condition="$vo.pid gt 0"}{:str_repeat('--',$vo.Count)}{/if}{$vo.c_name}</td>
                <td>{if condition ="$vo.enabled eq 1"}是{else/}否{/if}</td>
                <td><button class="btn btn-default"  @click="edit({$vo.id})" >修改</button> <button class="btn btn-danger" @click="del({$vo.id})">删除</button></td>
            </tr>
        {/volist}
        </tbody>
    </table>
</div>
<script>
    new Vue({
        el:'#main',
        methods:{
            edit:function(id){
              window.location.href="{:url('category/create')}?id="+id;
            },
            del:function(id){
                if(confirm('确定删除该分类')) {
                    ajax('./delete', {id: id},'get', function (re) {
                        if (re.status == 1){
                            window.location.reload()
                        }else{
                            alert(re.msg);
                        }
                    });
                }
            }
        }
    })
</script>
{/block}

